In this example, Access is used as an instance, and there are still many improvements.
Please improve yourself
Package product;Import java. SQL .*;Public class ConnectDB {String strDBDriver = "sun. jdbc. odbc. JdbcOdbcDriver ";String strConnstr =
1. SQLiteOpenHelper
SQliteOpenHelper is an abstract class used to manage database creation and version management. To use it, you must implement its nCreate (SQLiteDatabase), onUpgrade (SQLiteDatabase, int, int) method.
OnCreate: the database is
How to access the mysql database using java
1. Download the interface package mysql-connector-java-5.0.8-bin.jar
2. Programming
(1) load the driver
(2) programming connection operations
(3) return result Processing
Programming example
import
1. By reading the file configuration Packagedatabase operation class; /** Db.java Created on August 20, 2007, Morning 8:37*/ ImportJava.io.*; ImportJava.sql.*; Importjava.util.Properties; Public classDB {PrivateString driver; PrivateString URL;
I have learned jsp very well over the past few days. I have written a paging class to share it with you.
Part 1: db. MysqlConn database connection class
/*************************************** *******************
Path: zon. db. MysqlConn
File:
How to access the mysql database using java
1. Download the interface package mysql-connector-java-5.0.8-bin.jar
2. Programming
(1) load the driver
(2) programming connection operations
(3) return result Processing
Programming example
import
Link Java to mySQL database for addition, deletion, modification, and query Java link mySQL database code
Modification and query are the same for addition.
Public class JDBCTest {/*** ResultSet encapsulates the JDBC result set and query results */@
js| Package | data | database
Using beans in JSP to encapsulate the common features of a database
1. Create a Bean
Package guestbook; import java.sql.*; public class Sql_data { String sdbdriver= "Sun.jdbc.odbc.JdbcOdbcDriver"; String sconnstr=
Package Henu.utils;import java.sql.*;p ublic class dbutil{/** * Declares information about connected databases, such as database URL, user name, and password */private static final String U RL = "Jdbc:mysql://localhost:3306/userdb"; private static
1. The third Way is the most recommended!/** * Note that the database connected in 1.url must exist, such as Hello must exist, otherwise the error * 2.user and password is fixed, can not be written username or pass, otherwise error * @author Ckang *
Encapsulation for connecting java to mysql database
Public class DB { Static {Try {Class. forName ("com. mysql. jdbc. Driver ");} Catch (ClassNotFoundException e ){E. printStackTrace ();}} Private DB (){} Public static Connection getConn
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.